/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#include "statusbar.h"

StatusBar::StatusBar(GpsManager::gps_status gpsStatusInitial,
                     bool initialTrackingStatus,
                     bool mapsEnabled ) :
    FTMultiButton( FTControls::IconNormal, FTMultiButton::manual_select )
{
    enableClock( true );

    addButtonRight( BUTTON_TABLE, QImage(":/statusbar/table.png"), tr("Tracking Table") );

    // The status GPS status label
    addButtonRight( BUTTON_GPS, QImage(":/statusbar/gps_nofix.png"), tr("Manage GPS") );
    updateGpsStatus( gpsStatusInitial );

    // The LiveTrack tracking status label
    addButtonRight( BUTTON_LIVE, QImage(":/statusbar/livetrack_off.png"), tr("LiveTrack") );
    updateTrackingStatus(initialTrackingStatus);

    addButtonRight( BUTTON_MAPS, QImage(":/statusbar/maps_off.png"), tr("Manage maps") );
    updateMapsStatus( mapsEnabled );

    addButtonRight( BUTTON_TRACKS, QImage(":/statusbar/tracks.png"), tr("Manage tracks") );

    addButtonRight( BUTTON_SYSTEM, QImage(":/statusbar/system.png"), tr("System stuff") );

}

void StatusBar::updateGpsStatus(GpsManager::gps_status status)
{
    if ( status == GpsManager::disabled )
        setImage( BUTTON_GPS, QImage(":/statusbar/gps_disabled.png") );
    else if ( status == GpsManager::fix )
        setImage( BUTTON_GPS, QImage(":/statusbar/gps_fix.png") );
    else
        setImage( BUTTON_GPS, QImage(":/statusbar/gps_nofix.png") );
}

void StatusBar::updateTrackingStatus(bool trklv)
{
    if ( trklv )
        setImage( BUTTON_LIVE, QImage(":/statusbar/livetrack_on.png") );
    else
        setImage( BUTTON_LIVE, QImage(":/statusbar/livetrack_off.png") );
}

void StatusBar::updateMapsStatus(bool mps)
{
    if ( mps )
        setImage( BUTTON_MAPS, QImage(":/statusbar/maps_on.png") );
    else
        setImage( BUTTON_MAPS, QImage(":/statusbar/maps_off.png") );
}
